package gentle.service.impl;

import gentle.base.SqlMapper;
import gentle.entity.RechargeInfo;
import gentle.service.ICardDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional
public class CardDetailImpl implements ICardDetailService {

    @Autowired
    private SqlMapper sqlMapper;

    public List<RechargeInfo> getEarnestList(String reservationsId,String abbreviation){
        String ctable = abbreviation + "customer_info";
        String sql = "select t1.id,t2.customer_name as customerName,t2.customer_phone as customerPhone,t1.actual_account_balance as actualAccountBalance," +
                " t1.remarks as remarks,t1.recharge_people as rechargePeople,t1.recharge_time as rechargeTime,t1.checkout_method as checkoutMethod," +
                " t1.tc_name as tcName,t1.add_store as addStore,t1.mode as mode," +
                " (select customer_name from reservations_info where id=t1.reservations_idz limit 0,1) as customerNameZZ," +
                " (select customer_name from reservations_info where id=t1.reservations_ids limit 0,1) as customerNameSF  " +
                " from reserveMoney_deal t1 left join " + ctable+ " t2 on (t1.reservations_id=t2.reservations_id)  " +
                " where t1.reservations_id='" + reservationsId + "' group by t1.id order by t1.recharge_time desc ";
        List<RechargeInfo> rechargeInfo = sqlMapper.selectList(sql, RechargeInfo.class);
        return rechargeInfo;
    }
}